package com.tea.teawebsite.config;

import com.tea.teawebsite.component.LoginHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyMvcConfig implements WebMvcConfigurer {//扩展SpringMVC的功能

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**").excludePathPatterns("/","/hlogin.html","/login");
    }

    //注册视图控制器：页面上输入请求打开对应的视图
    @Override
    public void addViewControllers(ViewControllerRegistry registry){
        registry.addViewController("/").setViewName("hlogin");
        registry.addViewController("/hlogin.html").setViewName("hlogin");

        //打开主界面
       registry.addViewController("/hmain.html").setViewName("hmain");

    }

}
/*
@Configuration
public class MyMvcConfig extends WebMvcConfigurationSupport {//扩展SpringMVC的功能

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        //registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**").excludePathPatterns("/","/index.html","/login");
    }

    //注册视图控制器：页面上输入请求打开对应的视图
    @Override
    protected void addViewControllers(ViewControllerRegistry registry){
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/index.html").setViewName("login");

        //打开主界面
       registry.addViewController("/main.html").setViewName("main");

    }

}
*/
